import AESCrypto from './AESCrypto/AESCrypto';
import SmEnDe from './SmEnde';
import Pbkdf2Worker from './workers/pbkdf2.worker.js';

const kunlun = {
    sm: new SmEnDe(),
    aes: new AESCrypto(),
    pbkdf2: {
        getPbkdf2Key: (password, account) => {
            return new Promise((resolve, reject) => {
                const worker = new Pbkdf2Worker();
                worker.postMessage([password, account, 1000000, 32, 'sha256']);
                worker.onmessage = function (event) {
                    resolve(event.data);
                    worker.terminate(); //执行完毕结束worker
                };
                worker.onerror = function (err) {
                    reject(err);
                };
            });
        },
    },
};

export default kunlun;
